<template>
  <div class="c-tabs">
    <div class="items">
      <div v-for="(item, idx) in labels" :key="idx" :class="{ selected: idx === activeIndex }" @click="callback(idx)">{{ item }}</div>
    </div>
    <div class="right">
      <slot name="right"></slot>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Vue, Prop } from "vue-property-decorator";
import { Tabs } from "ant-design-vue";

@Component({
  name: "CTabs",
  components: {
    ATabs: Tabs,
    ATabPane: Tabs.TabPane
  }
})
export default class CTabs extends Vue {
  @Prop() labels!: string[];
  private activeIndex = 0;

  private callback(idx: number) {
    this.activeIndex = idx;
    this.$emit("click", { activeIndex: idx });
  }
}
</script>

<style lang="less" scoped>
@import "~@/assets/style/mixin.less";
.c-tabs {
  background: #ffffff;
  padding-right: 18px;
  padding-left: 24px;
  border-bottom: 1px solid #edeef0;
  color: #63696f;
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  // .scale(height, 44px);
  height: 44px;
  line-height: 44px;
  .items {
    display: flex;
    justify-content: flex-start;
    height: 100%;

    & > div {
      cursor: pointer;
      .scale(margin-left, 23px);
      // .scale(padding-top, 8px);
      height: 100%;
      &:first-child {
        margin-left: 0;
      }
    }
  }
  .right {
    padding: 8px 0px;
  }

  .selected {
    position: relative;
    color: #2674d5;
    &::after {
      content: "";
      position: absolute;
      background: url("~@/assets/images/bg-10.png") no-repeat;
      background-position-x: center;
      left: 0;
      right: 0;
      bottom: 0;
      height: 7px;
    }

    background-size: 79px auto;
  }
}
</style>
